package thread;

public class CurrentThreadDemo {
    public static void main(String[] args) {
        Thread main = Thread.currentThread();
        System.out.println(main);
        showThreadInfo();
    }

    public static void showThreadInfo(){
        Thread t = Thread.currentThread();
        System.out.println(t);

        //获取线程名字
        String name = t.getName();
        System.out.println(name);

        //获取线程id    id:表示唯一
        long id = t.getId();
        System.out.println(id);

        //获取线程优先级(1-10) 1最低, 10最高, 5为默认值
        int priority = t.getPriority();
        System.out.println(priority);

        //线程是否活着
        boolean isAlive = t.isAlive();

        //线程是否为守护线程
        boolean isDaemon = t.isDaemon();

        //线程是否被中断
        boolean isInterrupted = t.isInterrupted();

        System.out.println(isAlive);
        System.out.println(isDaemon);
        System.out.println(isInterrupted);
    }
}


